<%@ page contentType="application/json; charset=UTF-8" pageEncoding="UTF-8" errorPage="/error.jsp"%>
<%@page import="dbexp.connection.DbMetaData"%>
<%@page import="dbexp.model.db.DbUser"%>
<%@page import="dbexp.model.TableData"%>
<%@page import="org.json.JSONObject"%>
<%@page import="org.json.JSONArray"%>
<%@page import="java.util.List"%>
<%
DbUser u = (DbUser)session.getAttribute("USER");
String patern = request.getParameter("query");
final TableData tab =  DbMetaData.getAllSchemas(u,patern);
List<List<Object>> rows = tab.getRows();
JSONObject schems = new JSONObject();
JSONArray data = new JSONArray();
for (int i = 0; i < rows.size(); i++) {
	List<Object> row = rows.get(i);
	JSONObject schema = new JSONObject();
	for (int j = 0; j < row.size(); j++) {
		schema.put("name", row.get(j));
	}
	data.put(schema);
}
schems.put("data", data);
out.clearBuffer();%><%=schems.toString() %>